package com.xbongbong.paas.pojo;

import com.xbongbong.paas.field.FormulaPoJo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Map;

/**
 * @author: wufeng
 * @date: 2018/12/24 16:32
 * @desrcption: 操作
 */
@ToString
@Getter
@Setter
public class OperationsPojo implements Serializable {
    private static final long serialVersionUID = -2517851179509517214L;

    /**
     * 目标表单字段
     */
    @NotEmpty(message = "目标表单字段不能为空")
    private String attr;

    /**
     * 目标表单字段名称
     */
    private String attrName;
    /**
     * 字段类型
     */
    @NotNull(message = "字段类型不能为空")
    private Integer fieldType;

    /**
     * 操作标示，比如等于，加、减
     * @see com.xbongbong.paas.enums.LogicalSymbolEnum
     */
    @NotEmpty(message = "操作标示不能为空")
    private String symbol;

    /**
     * 值类型，1表示动态值，2表示固定值
     * @see com.xbongbong.pro.enums.businessrule.enums.RuleValueTypeEnum
     */
    @NotNull(message = "值类型不能为空")
    private Integer valueType;

    /**
     * 固定值类型的值
     */
    private Object value;
    /**
     * 给子表单赋值用的 格式{数据id：更新的数组}
     */

    private Map<Long, Object> subValue;


    /**
     * 动态值-当前表单对应的字段
     */
    private String valueAttr;
    /**
     * 动态值-当前表单对应的字段类型
     */
    private Integer valueFieldType;
    /**
     * 动态值-当前表单对应的字段名称
     */
    private String valueAttrName;

    /**
     * 公式
     */
    private FormulaPoJo formulaInfo;

    public OperationsPojo() {
    }

    public OperationsPojo(@NotEmpty(message = "目标表单字段不能为空") String attr, String attrName, @NotNull(message = "字段类型不能为空") Integer fieldType, @NotEmpty(message = "操作标示不能为空") String symbol,
                          @NotNull(message = "值类型不能为空") Integer valueType, Object value, String valueAttr, Integer valueFieldType, String valueAttrName, FormulaPoJo formulaInfo) {
        this.attr = attr;
        this.attrName = attrName;
        this.fieldType = fieldType;
        this.symbol = symbol;
        this.valueType = valueType;
        this.value = value;
        this.valueAttr = valueAttr;
        this.valueFieldType = valueFieldType;
        this.valueAttrName = valueAttrName;
        this.formulaInfo = formulaInfo;
    }
}
